package com.jwdf.uda.ui.adapter.viewholder;

import android.databinding.DataBindingUtil;
import android.view.View;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.databinding.ItemReplyLikeBinding;
import com.jwdf.uda.ui.activity.UserInfoActivity;
import com.jwdf.uda.ui.adapter.AbsViewHolder;
import com.jwdf.uda.ui.adapter.item.ReplyDetailItem;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by Administrator on 2016/9/19.
 */
public class ReplyUserLikeViewHolder extends AbsViewHolder<ReplyDetailItem> {

    private ItemReplyLikeBinding mItemBinding;

    public ReplyUserLikeViewHolder(View convertView) {
        super(convertView);
        mItemBinding = DataBindingUtil.bind(convertView);
        convertView.setOnClickListener(this);
    }

    @Override
    protected void onBindView(ReplyDetailItem item) {
        PbBean.PbUserSimple like = item.likeInfo;
        if (like == null) return;
        ImageLoader.getInstance().displayImage(like.getAvatar().getUrl(), mItemBinding.ivHeader);
        mItemBinding.tvName.setText(like.getNickname());
        mItemBinding.ivDesigner.setVisibility(View.GONE);
        mItemBinding.setIsDesigner(like.getIsDesigner());
    }

    @Override
    public void onClick(View v) {
        if (item.likeInfo != null) {
            UserInfoActivity.start(v.getContext(), item.likeInfo.getUserId(), item.likeInfo.getIsDesigner());
        }
    }
}
